package com.roc.service.impl;

import java.io.File;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;

import org.apache.log4j.Logger;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.roc.bean.FreezeBean;
import com.roc.bean.FreezeListBean;
import com.roc.dao.DaoException;
import com.roc.dao.IBaseDao;
import com.roc.dao.ISQLBaseDao;
import com.roc.pojo.Operators;
import com.roc.service.ServiceException;
import com.roc.service.freeze.IFreezeService;
import com.roc.util.Constance;
import com.roc.util.constant.SysLogType;
@Service
@Transactional
public class FreezeServiceImpl implements IFreezeService{
	
	static Logger logger=Logger.getLogger(FreezeServiceImpl.class);
	
	@Autowired
	private ISQLBaseDao sqlBaseDao;
	@Autowired
	private IBaseDao baseDao;
	@Override
	public int addFreezeMerInfo(FreezeBean bean,Operators op) throws ServiceException {
		String proIndexSQL="SELECT APSTFR.TBL_TFR_FREEZE_SEQ.NEXTVAL FROM  DUAL";//创建序列单独拿出便于记录到系统日志
		String sql="INSERT INTO APSTFR.TBL_TFR_MCHNT_FREEZE_LIST(KEY_STR,MCHNT_CD,FREEZE_AMT,FREEZE_HAD_SUM,"
				+ "FREEZE_WEI_SUM,USE_STATUS,FREEZE_FLAG,OLD_TRANS_KEY,OLD_TRANS_CARD_NO,RESVER1,RESVER2,REC_CRT_TS) VALUES(?,?,?,?,?,?,?,?,?,?,?,SYSTIMESTAMP)";
		int effect=0;
		String current=bean.getFreezeAmt();
		if(current==null){
			return effect;
		}
		try {
		Object obj=baseDao.createSQLQueryUniqueResult(proIndexSQL);
		double infactValue=Double.parseDouble(current)*100;//单位为元转换为分
		DecimalFormat df = new DecimalFormat("0");//取整去小数位存字符串
		List<Object> parmas=new ArrayList<Object>();
		parmas.add(Constance.Null2EmptyTrim(Long.parseLong(String.valueOf(obj))));
		parmas.add(Constance.Null2EmptyTrim(bean.getMchntCd()));
		parmas.add(Constance.Null2EmptyTrim(df.format(infactValue)));
		parmas.add(Constance.Null2EmptyTrim("0"));
		parmas.add(Constance.Null2EmptyTrim(df.format(infactValue)));
		parmas.add(Constance.Null2EmptyTrim("1"));
		parmas.add(Constance.Null2EmptyTrim("0"));
		parmas.add(Constance.Null2EmptyTrim(bean.getOldTransKey()));
		parmas.add(Constance.Null2EmptyTrim(bean.getOldTransCardNo()));
		parmas.add(Constance.Null2EmptyTrim(bean.getRemark()));
		parmas.add(Constance.Null2EmptyTrim(op.getAccountNo()));
			effect=sqlBaseDao.deleteBySql(sql, parmas);
			if(effect>0)
			{
				logger.info("添加【"+bean.getMchntCd()+"】到冻结商户成功!");
				baseDao.addSyslog(SysLogType.FREEZE_MCHT_QK_ADD.getCode(), SysLogType.FREEZE_MCHT_QK_ADD.getName(), op.getAccountNo(),String.valueOf(obj));
			}
		} catch (DaoException e) {
			logger.debug(e.getMessage(),e);
			throw new ServiceException("添加冻结商户失败");
		}
		return effect;
	}

	@Override
	public int updateFreezeMerInfo(FreezeBean bean,Operators op) throws ServiceException {
		String sql="UPDATE  APSTFR.TBL_TFR_MCHNT_FREEZE_LIST SET USE_STATUS=?,RESVER1=?,RESVER2=?,REC_UPD_TS=SYSTIMESTAMP WHERE KEY_STR=?";
		int effect=0;
		try {
		List<Object> parmas=new ArrayList<Object>();
		parmas.add(Constance.Null2EmptyTrim(bean.getUseStatus()));
		parmas.add(Constance.Null2EmptyTrim(bean.getRemark()));
		parmas.add(Constance.Null2EmptyTrim(op.getAccountNo()));
		parmas.add(Constance.Null2EmptyTrim(bean.getKeyStr()));
			effect=sqlBaseDao.deleteBySql(sql, parmas);
			if(effect>0)
			{
				logger.info("更改冻结商户【"+bean.getMchntCd()+"】成功!");
				baseDao.addSyslog(SysLogType.FREEZE_MCHT_QK_UPDATE.getCode(), SysLogType.FREEZE_MCHT_QK_UPDATE.getName(), op.getAccountNo(), String.valueOf(bean.getKeyStr()));
			}
		} catch (DaoException e) {
			logger.debug(e.getMessage(),e);
			throw new ServiceException("更改冻结商户");
		}
		return effect;
	}

	@Override
	public FreezeBean findMerInfo(FreezeBean bean) throws ServiceException {
		String sql="SELECT KEY_STR,MCHNT_CD,FREEZE_AMT,FREEZE_HAD_SUM,FREEZE_WEI_SUM,USE_STATUS,FREEZE_FLAG,OLD_TRANS_KEY,OLD_TRANS_CARD_NO,RESVER1 FROM APSTFR.TBL_TFR_MCHNT_FREEZE_LIST WHERE KEY_STR=?";
		Object[] parmas={bean.getKeyStr()};
		FreezeBean ibean=null;
		try {
			Object object=sqlBaseDao.findObj(sql, parmas);
			if(object!=null)
			{
				Object[] obj=(Object[]) object;
				ibean=new FreezeBean();
				ibean.setKeyStr(Long.parseLong(Constance.Null2EmptyTrim(obj[0])));
				ibean.setMchntCd(Constance.Null2EmptyTrim(obj[1]));
				DecimalFormat df=new DecimalFormat("0.00");
				ibean.setFreezeAmt(df.format(Double.parseDouble(Constance.Null2EmptyTrim(obj[2]))/100));
				ibean.setFreezeHadSum(df.format(Double.parseDouble(Constance.Null2EmptyTrim(obj[3]))/100));
				ibean.setFreezeWeiSum(df.format(Double.parseDouble(Constance.Null2EmptyTrim(obj[4]))/100));
				ibean.setUseStatus(Constance.Null2EmptyTrim(obj[5]));
				ibean.setFreezeFlag(Constance.Null2EmptyTrim(obj[6]));
				ibean.setOldTransKey(Constance.Null2EmptyTrim(obj[7]));
				ibean.setOldTransCardNo(Constance.Null2EmptyTrim(obj[8]));
				ibean.setRemark(Constance.Null2EmptyTrim(obj[9]));
			}
		} catch (DaoException e) {
			logger.debug(e.getMessage(),e);
			throw new ServiceException("查询【"+bean.getMchntCd()+"】失败");
		}
		return ibean;
	}

	
	@Override
	public List<FreezeListBean> findByKey(String keyStr) throws ServiceException {
		List<FreezeListBean> fList = new ArrayList<FreezeListBean>();
		String sql = " select t.key_str,t.over_freeze_amt,t.hai_need_freeze_amt,t.now_freeze_amt,t.trans_dt,t.trans_tm,t.proc_st,t.ma_settle_dt,t.mchnt_cd,t.term_id,t.card_accptr_nm,t.tran_dt_tm,t.pye_bank_no,t.pye_bank_nm,t.pye_acct_no,t.pye_acct_nm,t.pri_bank_no,t.pri_bank_nm,t.pri_acct_no,t.tran_amt,t.mcht_stlm_fee,t.t0_stlm_fee,t.stlm_amt from apstfr.TBL_TFR_trn_freeze_log t where t.key_str =? ";
		Object[] objParma={keyStr};
		try {
			List<?> objList = sqlBaseDao.queryAll(sql, objParma);
			logger.info("根据key值【"+keyStr+"】查询出匹配的冻结流水【"+objList.size()+"】条");
			if(null != objList && objList.size()>0){
				Iterator<?> iterator=objList.iterator();
				while(iterator.hasNext()){
					Object[] obj = (Object[]) iterator.next();
					
					DecimalFormat df=new DecimalFormat("#.##");//数据库存的分，转成元保留小数点后两位  
					String overFreezeAmt_temp=Constance.Null2EmptyTrim(obj[1]);
					String haiNeedFreezeAmt_temp=Constance.Null2EmptyTrim(obj[2]);
					String nowFreezeAmt_temp=Constance.Null2EmptyTrim(obj[3]);
					String tranAmt_temp=Constance.Null2EmptyTrim(obj[19]);
					String mchtStlmFee_temp=Constance.Null2EmptyTrim(obj[20]);
					String t0StlmFee_temp=Constance.Null2EmptyTrim(obj[21]);
					String stlmAmt_temp=Constance.Null2EmptyTrim(obj[22]);
					double overFreezeAmt,haiNeedFreezeAmt,nowFreezeAmt,tranAmt,mchtStlmFee,t0StlmFee,stlmAmt;
					if(!"".equals(overFreezeAmt_temp)){
						overFreezeAmt=Double.parseDouble(overFreezeAmt_temp);
					}else{
						overFreezeAmt=0.00;
					}
					if(!"".equals(haiNeedFreezeAmt_temp)){
						haiNeedFreezeAmt=Double.parseDouble(haiNeedFreezeAmt_temp);
					}else{
						haiNeedFreezeAmt=0.00;
					}
					if(!"".equals(nowFreezeAmt_temp)){
						nowFreezeAmt=Double.parseDouble(nowFreezeAmt_temp);
					}else{
						nowFreezeAmt=0.00;
					}
					if(!"".equals(tranAmt_temp)){
						tranAmt=Double.parseDouble(tranAmt_temp);
					}else{
						tranAmt=0.00;
					}
					if(!"".equals(mchtStlmFee_temp)){
						mchtStlmFee=Double.parseDouble(mchtStlmFee_temp);
					}else{
						mchtStlmFee=0.00;
					}
					if(!"".equals(t0StlmFee_temp)){
						t0StlmFee=Double.parseDouble(t0StlmFee_temp);
					}else{
						t0StlmFee=0.00;
					}
					if(!"".equals(stlmAmt_temp)){
						stlmAmt=Double.parseDouble(stlmAmt_temp);
					}else{
						stlmAmt=0.00;
					}
				
					FreezeListBean fb = new FreezeListBean();
					fb.setKeyStr(Long.parseLong(Constance.Null2EmptyTrim(obj[0])));
					fb.setOverFreezeAmt((df.format(overFreezeAmt/100)).toString());
					fb.setHaiNeedFreezeAmt((df.format(haiNeedFreezeAmt/100)).toString());
					fb.setNowFreezeAmt((df.format(nowFreezeAmt/100)).toString());
					fb.setTransDt(Constance.Null2EmptyTrim(obj[4]));
					fb.setTransTm(Constance.Null2EmptyTrim(obj[5]));
					fb.setProcSt(Constance.Null2EmptyTrim(obj[6]));
					fb.setMaSettleDt(Constance.Null2EmptyTrim(obj[7]));
					fb.setMchntCd(Constance.Null2EmptyTrim(obj[8]));
					fb.setTermId(Constance.Null2EmptyTrim(obj[9]));
					fb.setCardAccptrNm(Constance.Null2EmptyTrim(obj[10]));
					fb.setTranDtTm(Constance.Null2EmptyTrim(obj[11]));
					fb.setPyeBankNo(Constance.Null2EmptyTrim(obj[12]));
					fb.setPyeBankNm(Constance.Null2EmptyTrim(obj[13]));
					fb.setPyeAcctNo(Constance.Null2EmptyTrim(obj[14]));
					fb.setPyeAcctNm(Constance.Null2EmptyTrim(obj[15]));
					fb.setPriBankNo(Constance.Null2EmptyTrim(obj[16]));
					fb.setPriBankNm(Constance.Null2EmptyTrim(obj[17]));
					fb.setPriAcctNo(Constance.Null2EmptyTrim(obj[18]));
					fb.setTranAmt((df.format(tranAmt/100)).toString());
					fb.setMchtStlmFee((df.format(mchtStlmFee/100)).toString());
					fb.setT0StlmFee((df.format(t0StlmFee/100)).toString());
					fb.setStlmAmt((df.format(stlmAmt/100)).toString());
					fList.add(fb);
					
				}
				
			}
			
		} catch (Exception e) {
			logger.debug(e.getMessage(),e);
			throw new ServiceException("查询【"+keyStr+"】匹配的冻结流水失败");
			
		}
		return fList;
	}
	/**
	 * 查询该冻结记录的操作日志
	 */
	@Override
	public List<Object> findSyslogByKey(String keyStr) throws ServiceException {
		List<Object> syslogList=new ArrayList<Object>();
		String sql="select to_char(t.dt_lastmod, 'yyyy-MM-dd hh24:mi:ss') ldate, t.operators loperators, t.oper_name lname  from t_syslog t  where t.oper_code in ('077', '078','095') and t.log_context = ? order by t.id asc";
		logger.info(sql.toString());
		Object[] objParma={keyStr};
		try {
			List<?> objList= sqlBaseDao.queryAll(sql, objParma);
			logger.info("根据key值【"+keyStr+"】查询出匹配的冻结流水的操作记录");
			if(null != objList && objList.size()>0){
				Iterator<?> iterator=objList.iterator();
				while(iterator.hasNext()){
					HashMap<String, String> res=new HashMap<String, String>();
					Object[] obj = (Object[]) iterator.next();
					res.put("ldate",obj[0].toString());
					res.put("loperators",obj[1].toString());
					res.put("lname",obj[2].toString());
					syslogList.add(res);
				}
			} 
		} catch (Exception e) {
			logger.debug(e.getMessage(),e);
			throw new ServiceException("查询【"+keyStr+"】匹配的冻结流水的操作记录失败");
			
		}
		return syslogList;
	}
	@Override
	public Map<String, Object> insertFreezeList(File file, Operators op,String flag)
			throws ServiceException {
		Map<Integer,List<Object>> uploadData=new HashMap<Integer, List<Object>>();//存放上传数据
		Map<String,Object> resultMap=new HashMap<String, Object>();//上传文件错误原因及定位
		int count=0;
		try{
			//上传Excel文件流转换为Map集合
			logger.info("上传Excel文件流转换为Map集合");
			boolean uploadResult=transfromToExcel(file,uploadData,resultMap,flag);
			if(!uploadResult)
			{
				return resultMap;//返回错误原因
			}
			//验证Excel表数据正确性
			logger.info("验证Excel表数据正确性");
			boolean correntValidate=verifyDataCorrectness(uploadData, resultMap,flag);
			if(!correntValidate)
			{
				return resultMap;//返回校验原因
			}
			//导入数据库
			logger.info("开始进行批量导入操作");
			if("0".equals(flag)){//新增
				Iterator<Entry<Integer, List<Object>>> it=uploadData.entrySet().iterator();			
				//开始导入数据
				while(it.hasNext())
				{
					Entry<Integer, List<Object>> entry=it.next();
					List<Object> list=entry.getValue();
					//循环列
					FreezeBean bean = new FreezeBean();
					bean.setMchntCd(Constance.Null2EmptyTrim(list.get(0)));
					bean.setFreezeAmt(Constance.Null2EmptyTrim(list.get(1)));
					bean.setOldTransKey(Constance.Null2EmptyTrim(list.get(2)));
					bean.setOldTransCardNo(Constance.Null2EmptyTrim(list.get(3)));
					bean.setRemark(Constance.Null2EmptyTrim(list.get(4)));
					addFreezeMerInfo(bean, op);
					count++;
				}
				resultMap.put("result","导入成功!总计导入"+count+"条数据");
			}else if("1".equals(flag)){//修改
				Iterator<Entry<Integer, List<Object>>> it=uploadData.entrySet().iterator();			
				while(it.hasNext())
				{
					Entry<Integer, List<Object>> entry=it.next();
					List<Object> list=entry.getValue();
					//循环列
					FreezeBean bean = new FreezeBean();					
					bean.setMchntCd(Constance.Null2EmptyTrim(list.get(0)));
					bean.setKeyStr(Long.parseLong(Constance.Null2EmptyTrim(list.get(1))));
					String status=Constance.Null2EmptyTrim(list.get(2));
					if("是".equals(status)){
						bean.setUseStatus("1");
					}else if("否".equals(status)){
						bean.setUseStatus("0");
					}					
					int rows=updateFlag(bean, op);
					if(rows>0){
						count++;
					}else{
						resultMap.put("result","前"+count+"条修改成功!ID为"+bean.getKeyStr()+"的修改失败!");
						return resultMap;
					}
					resultMap.put("result","导入成功!总计修改"+count+"条数据");
				}
			}
			logger.info("批量导入操作完成");
		}catch(Exception e){
			logger.debug(e.getMessage(), e);
			throw new ServiceException("批量导入强扣失败");
		}
		return resultMap;
	}
	
	/**
	 * 将File装换成Map集合
	 * @param file
	 * @param map
	 */
	@SuppressWarnings("deprecation")
	protected boolean transfromToExcel(File file,Map<Integer,List<Object>> map,Map<String,Object> resultMap,String flag)
	{
		try {
			// 构造 XSSFWorkbook 对象，strPath 传入文件路径
			XSSFWorkbook xwb = new XSSFWorkbook(file.getPath());
			// 得到Excel工作表对象
			XSSFSheet sheet = xwb.getSheetAt(0);
			// 得到行数
			int trLength = sheet.getPhysicalNumberOfRows();
			if(trLength == 0){
				logger.info("上传文件缺少列名");
				resultMap.put("result", "上传文件缺少列名");
				return false;
			}			
			logger.info("Excel中记录的总行数是：" + (trLength - 1));			
			// 每条记录列数
			Row row = sheet.getRow(0);
			int tdLength = row.getPhysicalNumberOfCells();
			String[] title=null;
			String[] temp1={"商户号","冻结总金额","原调单流水","交易卡号","备注"};
			String[] temp2={"商户号","ID","是否启用"};
			if("0".equals(flag)){			
				if(tdLength<5){
					logger.info("上传的文件缺少必需的列名");
					resultMap.put("result", "上传的文件缺少必需的列名");
					return false;
				}
				if(tdLength>5){
					logger.info("上传的文件存在多余的列名");
					resultMap.put("result", "上传的文件存在多余的列名");
					return false;
				}
				title=new String[5];
				for(int i=0;i<temp1.length;i++){
					title[i]=temp1[i];
				}
			}else if("1".equals(flag)){
				if(tdLength<3){
					logger.info("上传的文件缺少必需的列名");
					resultMap.put("result", "上传的文件缺少必需的列名");
					return false;
				}
				if(tdLength>3){
					logger.info("上传的文件存在多余的列名");
					resultMap.put("result", "上传的文件存在多余的列名");
					return false;
				}
				title=new String[3];
				for(int i=0;i<temp2.length;i++){
					title[i]=temp2[i];
				}
			}
			
			logger.info("每条记录的列数："+tdLength);
				
			//验证标题是否一致
			String reason_error=null;
			String titleName=null;
			for(int i=0;i<title.length;i++)
			{
				row.getCell(i).setCellType(Cell.CELL_TYPE_STRING);
				titleName=row.getCell(i).getStringCellValue();
				if(!titleName.equals(title[i]))
				{
					reason_error="第1行第"+(i+1)+"列的列名不正确,正确的列名为【"+title[i]+"】";
					logger.info(reason_error);
					resultMap.put("result", reason_error);
					return false;
				}
			}
			if(trLength == 1){
				logger.info("上传文件内容为空");
				resultMap.put("result", "上传文件内容为空");
				return false;
			}
			for (int i = 1; i < trLength; i++) {
				List<Object> tdList = new ArrayList<Object>();
				Row r = sheet.getRow(i);
				
				for (int j = 0; j < tdLength; j++) {
					Cell c = r.getCell(j);
					/*
					 * 将所有列的内容都设置成String类型，否则会出Excel异常： Cannot get a text value
					 * from a numeric cell
					 */
					if (c != null) {
						c.setCellType(Cell.CELL_TYPE_STRING);
						tdList.add(c.getStringCellValue());
					}else{
						tdList.add("");
					}					
				}
				map.put(i, tdList);
			}
		} catch (Exception e) {
			logger.error("将Excel中数据封装到List容器中异常：" + e.getMessage());
			resultMap.put("result", "将Excel中数据封装到List容器中异常");
			return false;
		}
		return true;
	}
	/**
	 * 验证数据正确性
	 * @param map
	 */
	public boolean verifyDataCorrectness(Map<Integer,List<Object>> map,Map<String,Object> resultMap,String flag)
	{
		Iterator<Entry<Integer, List<Object>>> it=map.entrySet().iterator();
		String error_reason=null;
		while(it.hasNext())
		{
			Entry<Integer, List<Object>> entry=it.next();
			List<Object> list=entry.getValue();			
			//商户号
			String regex="^\\d{15}$";
			String num=Constance.Null2EmptyTrim(list.get(0));
			if(!Pattern.matches(regex,num))
			{
				error_reason="第"+(entry.getKey()+1)+"行第1列商户号只能包含数字字符且长度为15，也不能为空";
				logger.info(error_reason);
				resultMap.put("result", error_reason);
				return false;
			}
			if("0".equals(flag)){
				String amtStr=Constance.Null2EmptyTrim(list.get(1));
				String amt_regex="^([1-9][\\d]{0,9}|0)(\\.[\\d]{1,2})?$";
				String un_amt_regex="^[0](\\.[0]{1,2})?$";
				if(!Pattern.matches(amt_regex,amtStr) || Pattern.matches(un_amt_regex, amtStr))//符合金额取值
				{
					error_reason="第"+(entry.getKey()+1)+"行第2列冻结金额只能取0~9999999999.99且不能为0,最多2位小数";
					logger.info(error_reason);
					resultMap.put("result", error_reason);
					return false;
				}
				String oldTransKey=Constance.Null2EmptyTrim(list.get(2));
				if(oldTransKey.length()>64)
				{
					error_reason="第"+(entry.getKey()+1)+"行第3列原调单流水长度不能超过64";
					logger.info(error_reason);
					resultMap.put("result", error_reason);
					return false;
				}
				String oldTransCardNo=Constance.Null2EmptyTrim(list.get(3));
				if(oldTransCardNo.length()>32)
				{
					error_reason="第"+(entry.getKey()+1)+"行第4列交易卡号长度不能超过32";
					logger.info(error_reason);
					resultMap.put("result", error_reason);
					return false;
				}
				String remark=Constance.Null2EmptyTrim(list.get(4));
				if(remark.length()>200 || "".equals(remark))
				{
					error_reason="第"+(entry.getKey()+1)+"行第5列备注不能为空且长度不能超过200";
					logger.info(error_reason);
					resultMap.put("result", error_reason);
					return false;
				}
			}
			else if("1".equals(flag)){
				String dates=Constance.Null2EmptyTrim(list.get(1));
				String regex_date="^\\d+$";
				if(!Pattern.matches(regex_date,dates))//主键ID
				{
					error_reason="第"+(entry.getKey()+1)+"行第2列ID只能为数字,具体ID请查看查询页面";
					logger.info(error_reason);
					resultMap.put("result", error_reason);
					return false;
				}
				String status=Constance.Null2EmptyTrim(list.get(2));
				if(!"是".equals(status)&&!"否".equals(status))
				{
					error_reason="第"+(entry.getKey()+1)+"行第3列是否启用只能填写是或者否";
					logger.info(error_reason);
					resultMap.put("result", error_reason);
					return false;
				}
			}
		}
		return true;
	}
	
	protected int updateFlag(FreezeBean bean,Operators op) throws Exception{
		int effect=0;
		try {
			String sql="UPDATE APSTFR.TBL_TFR_MCHNT_FREEZE_LIST SET USE_STATUS=?,RESVER2=? WHERE MCHNT_CD=? AND KEY_STR=?";
			List<Object> list=new ArrayList<Object>();
			list.add(bean.getUseStatus());
			list.add(op.getAccountNo());
			list.add(bean.getMchntCd());
			list.add(bean.getKeyStr());
			effect=sqlBaseDao.deleteBySql(sql,list);		
			baseDao.addSyslog(SysLogType.FREEZE_MCHT_QK_UPDATE.getCode(), SysLogType.FREEZE_MCHT_QK_UPDATE.getName(), op.getAccountNo(), String.valueOf(bean.getKeyStr()));
		} catch (DaoException e) {
			logger.debug(e.getMessage(),e);
			throw new ServiceException("修改商户启用状态失败");
		}
		return effect;
	}
}
